// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import _ from 'underscore'

Vue.config.productionTip = false

// 将全局样式文件写在 main.js
import '@/assets/scss/reset.scss'
import '@/assets/scss/iconfont.scss'
import requests from '@/utils/request';

Vue.use({
  install(Vue, options) {
    //注册全局方法，如常用的接口方法，工具方法等。
    _.each(requests, (item, key) => {
      Vue.prototype['$$' + key] = item;
    });
  }
});

import {
  ToastPlugin,
  AlertPlugin,
  ConfirmPlugin
} from 'vux'
Vue.use(ToastPlugin)
Vue.use(AlertPlugin)
Vue.use(ConfirmPlugin)

// 图片懒加载
import VueLazyload from 'vue-lazyload'
Vue.use(VueLazyload, {
  loading: '/static/loading-bars.svg',
  more: '/static/more.png'
  // loading: require('@/assets/img/logo.png')
})

import store from './store/';

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: { App }
})

// import { init } from './wx'
// init()

Vue.directive('title', {
  inserted: function (el, binding) {
    document.title = el.innerText
    el.remove()
  }
})

import moment from 'moment'
Vue.filter('date', function (time) {
  return moment(time).format('YYYY-MM-DD hh:mm')
})
